﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="veiculo_cadastro_formulario.aspx.cs" Inherits="softsales.pagina.veiculo_cadastro.veiculo_cadastro_formulario" %>
<%@ MasterType VirtualPath="~/Site.Master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Cabecalho" runat="server">
 <script type="text/javascript">
     function onOkPost() {
         __doPostBack();
     }

</script>
 <script type="text/javascript">
     $(document).ready(function () {


         // CLIENTE
         $("#<%=TXT_ID_CLI_FOR.ClientID %>").blur(function () {
             var id = $("#<%=TXT_ID_CLI_FOR.ClientID %>").val();

             if (id != "") {
                 $.ajax({
                     url: "../cadastro/cadastro.asmx/SelecionarPorId",
                     type: "post",
                     dataType: "json",
                     data: "{id:'" + id + "' }",
                     contentType: "application/json; charset=utf-8",
                     success: function (data) {
                         if (data.d != "null") {
                             var resultado = $.parseJSON(data.d);
                             $("#<%=TXT_NOME_CLI_FOR.ClientID %>").val(resultado.nome);
                             $("#<%=TXT_CNPJ_CPF.ClientID %>").val(resultado.cnpj_cpf);
                         }
                         else {
                             alert("Nenhum registro encontrado");
                             $("#<%=TXT_NOME_CLI_FOR.ClientID %>").val("");
                             $("#<%=TXT_ID_CLI_FOR.ClientID %>").val("");

                         }

                     },
                     error: function () {
                         alert("Erro ao tentar consultar ajax Fornecedor");
                         $("#<%=TXT_NOME_CLI_FOR.ClientID %>").val("");
                         $("#<%=TXT_ID_CLI_FOR.ClientID %>").val("");
                     }


                 });
             }
         });


         //Recuperando a instância ativa da classe PageRequestManager.
         var prm = Sys.WebForms.PageRequestManager.getInstance();
         if (prm != null) {
             //Registrando uma chamada a função inicializa() após o fim da renderização parcial da página.
             prm.add_endRequest(function () {
                 inicializa();
             });
         }

     });
</script>


</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ConteudoPrincipal" runat="server">
		
			<div class="inner-page-title">
				<h2><asp:Label ID="LBL_TITULO_PAGINA" runat="server" Text="tb_veiculo_cadastro"></asp:Label></h2>
					
				</div>	
		
<%--CADASTRO--%>
<asp:Panel ID="PNL_MODAL_CLI_FOR" runat="server" style="display:none;background:#fff;padding:5px;border:2px solid #000;">
<iframe id="Iframe1" src="../cliente/cliente_modal.aspx" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" height="300px" width="800px" runat="server" ></iframe>

<div class="clear"></div>
<asp:Button ID="BTN_SELECIONAR_CLI_FOR" runat="server" Text="SELECIONAR" 
CausesValidation="False" />
<asp:Button ID="BTN_FECHAR_CLI_FOR" runat="server" Text="FECHAR"  
CausesValidation="False"/>
</asp:Panel>


		<div class="content-box">
            <asp:TabContainer ID="TAB_CONTAINER" runat="server" ActiveTabIndex="1" 
                Width="100%">
                <asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TAB_CLIENTE">
                <HeaderTemplate>Cliente</HeaderTemplate>
                <ContentTemplate>
                <div class="softsales-form">
                	<div class="softsales-form-linha">		
		    <div class="grid_2">
		<!-- CAMPO INTEIRO -->
				<label for="Label_ID_CADASTRO">ID_CADASTRO</label>
				<div class="softsales-form-campo"><asp:TextBox ID="TXT_ID_CLI_FOR" CssClass="campo-text large requerido" runat="server"></asp:TextBox>
                    <asp:ImageButton ID="IMG_BTN_ABRIR_MODAL_CLI_FOR" runat="server"  CausesValidation="False" ImageUrl="~/images/icons/application.gif"  />
<asp:ModalPopupExtender ID="IMG_BTN_ABRIR_MODAL_CLI_FOR_ModalPopupExtender" runat="server" DynamicServicePath="" Enabled="True" BackgroundCssClass="softsales-modal-background" 
CancelControlID="BTN_FECHAR_CLI_FOR"   OnOkScript="onOkPost()" PopupControlID="PNL_MODAL_CLI_FOR"  OkControlID="BTN_SELECIONAR_CLI_FOR" TargetControlID="IMG_BTN_ABRIR_MODAL_CLI_FOR">
</asp:ModalPopupExtender>
                </div>
				<div class="softsales-form-error"><asp:RequiredFieldValidator ID="RFV_ID_CADASTRO" ControlToValidate="TXT_ID_CLI_FOR" runat="server" ErrorMessage="Campo Requerido"></asp:RequiredFieldValidator></div>
		</div>

           <div class="grid_8">
           	<label for="Label_NOME">NOME</label>
				<div class="softsales-form-campo"><asp:TextBox ID="TXT_NOME_CLI_FOR" CssClass="campo-text full requerido" runat="server"></asp:TextBox></div>
				<div class="softsales-form-error"><asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="TXT_NOME_CLI_FOR" runat="server" ErrorMessage="Campo Requerido"></asp:RequiredFieldValidator></div>

           </div>

            <div class="grid_2">
            	<label for="Label_CNPJ_CPF">CNPJ/CPF</label>
				<div class="softsales-form-campo"><asp:TextBox ID="TXT_CNPJ_CPF" CssClass="campo-text large apenas_numeros requerido" runat="server"></asp:TextBox></div>
				<div class="softsales-form-error"><asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="TXT_CNPJ_CPF" runat="server" ErrorMessage="Campo Requerido"></asp:RequiredFieldValidator></div>

            </div>
         

           <div class="clear"></div>

		</div>
                
                </div>
                
                
                </ContentTemplate>
                </asp:TabPanel>
                <asp:TabPanel ID="TAB_VEICULO" runat="server" HeaderText="TabPanel2">
                 <HeaderTemplate>Veículos</HeaderTemplate>
                <ContentTemplate>
                




   <div class="softsales-form">
<div class="softsales-form-linha">

<div class="float-left width50">
<div class="inner-page-title">
				 <h2>Filtro de Veículos</h2>
					
				</div>	
   
                 	
             <div class="softsales-form-linha">           
              <div class="grid_12">
           	<label for="Label_MARCA">MARCA</label>
				<div class="softsales-form-campo"><asp:DropDownList ID="DDL_ID_MARCA" 
                        CssClass="campo-text full" runat="server" 
                       ></asp:DropDownList></div>				

           </div>

           </div>

           <div class="softsales-form-linha">   
            <div class="grid_12">
           	<label for="Label_MODELO">MODELO</label>
				<div class="softsales-form-campo"><asp:DropDownList ID="DDL_ID_MODELO" 
                        CssClass="campo-text full" runat="server" 
                       ></asp:DropDownList></div>				

           </div>

           </div>
            <div class="softsales-form-linha">   
           <div class="grid_12">
           	<label for="Label_CATEGORIA">CATEGORIA</label>
				<div class="softsales-form-campo"><asp:DropDownList ID="DDL_ID_CATEGORIA" 
                        CssClass="campo-text full" runat="server" 
                       ></asp:DropDownList></div>				

           </div>

           </div>

            <div class="softsales-form-linha">   
           <div class="grid_3">
           	<label for="Label_PLACA">PLACA</label>
				<div class="softsales-form-campo"><asp:TextBox ID="TXT_PLACA" 
                        CssClass="campo-text full placa" runat="server" 
                       ></asp:TextBox></div>				

           </div>

            <div class="grid_3">
           	<label for="Label_UF">UF</label>
				<div class="softsales-form-campo"><asp:DropDownList ID="DDL_ID_UF" 
                        CssClass="campo-text full" runat="server" 
                       ></asp:DropDownList></div>				

           </div>

            <div class="grid_6">
                <div class="float-right">
                <asp:Button ID="BTN_FILTRAR" runat="server" Text="FILTRAR" 
                        onclick="BTN_FILTRAR_Click" />
                </div>
            </div>
           <div class="clear"></div>
           </div>
          

		
	
		</div>
                    
<div class="float-right width50">
<div class="softsales-tabela">
<div class="inner-page-title">
				 <h2>Lista de Veículos</h2>
					
				</div>	
 <asp:GridView ID="GRV_TB_VEICULO" runat="server" 
        onsorting="GRV_TB_VEICULO_Sorting" AllowSorting="True" 
        onpageindexchanging="GRV_TB_VEICULO_PageIndexChanging" 
        AutoGenerateColumns="False" DataKeyNames="id" EnableModelValidation="True" 
        onselectedindexchanged="GRV_TB_VEICULO_SelectedIndexChanged">	  
	<HeaderStyle CssClass="headerGridView" />
	<RowStyle CssClass="itemGridView" />
   	<PagerStyle CssClass="pagerGridView"  />
	<FooterStyle CssClass="footerGridView" />
        <Columns>          
			
				<asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="CHK_ID" runat="server" 
                            oncheckedchanged="CHK_ID_CheckedChanged" />
                    </ItemTemplate>
                </asp:TemplateField>
			
				<asp:BoundField DataField="id" HeaderText="ID" 
                SortExpression="id"  />											
				<asp:BoundField DataField="marca" HeaderText="ID_MARCA" 
                SortExpression="marca"  />											
				<asp:BoundField DataField="modelo" HeaderText="ID_MODELO" 
                SortExpression="modelo"  />													
				<asp:BoundField DataField="placa" HeaderText="PLACA" 
                SortExpression="placa"  />											
				<asp:BoundField DataField="id_uf" HeaderText="ID_UF" 
                SortExpression="id_uf"  />											
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:ImageButton ID="IMG_BTN_EDITAR" runat="server" 
                        ImageUrl="~/images/icons/action_edit.gif"  onclick="IMG_BTN_EDITAR_Click"   />
                    &nbsp;<asp:ImageButton ID="IMG_BTN_EXCLUIR" runat="server" ImageUrl="~/images/icons/action_delete.gif"  onclick="IMG_BTN_EXCLUIR_Click"    />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
	
	    </div>

    <div class="softsales-form-navegacao">
    <div class="float-left">
        <asp:Label ID="Label3" runat="server" Text="P?gina: "></asp:Label>
        <asp:Label ID="LBL_PAGINA_ATUAL" runat="server"></asp:Label>
        <asp:Label ID="Label4" runat="server" Text=" de  "></asp:Label>
        <asp:Label ID="LBL_PAGINA_TOTAL" runat="server" Text="LBL_PAGINA_TOTAL"></asp:Label>
    </div>
    <div class="float-right">
        <table>
        <tr>
        <td>
        <asp:ImageButton ID="IMG_BTN_PRIMEIRO" runat="server" 
            ImageUrl="~/images/icons/first.gif" onclick="IMG_BTN_PRIMEIRO_Click" />
            </td>
            <td>
        <asp:ImageButton ID="IMG_BTN_ANTERIOR" runat="server" 
            ImageUrl="~/images/icons/previous.gif" onclick="IMG_BTN_ANTERIOR_Click" />
            </td>
            <td>
        <asp:ImageButton ID="IMG_BTN_PROXIMO" runat="server" 
            ImageUrl="~/images/icons/forward.gif" onclick="IMG_BTN_PROXIMO_Click" />
            </td>
            <td>
        <asp:ImageButton ID="IMG_BTN_ULTIMO" runat="server" 
            ImageUrl="~/images/icons/last.gif" onclick="IMG_BTN_ULTIMO_Click" />
            </td>
            </tr>
            </table>
    </div>
    <div class="clear"></div>

    </div>

</div>

<div class="clear"></div>
</div>
</div>

<div class="softsales-form">
    <div class="softsales-form-linha">
    
        <p align="center" >
        <asp:Button ID="BTN_INCLUIR_VEICULO" runat="server" Text="INCLUIR VEÍCULO" 
                onclick="BTN_INCLUIR_VEICULO_Click" />
        <asp:Button ID="BTN_REMOVER_VEICULO" runat="server" Text="REMOVER VEÍCULO" />
        </p>
    
    </div>

</div>

<div class="softsales-form">
   <div class="inner-page-title">
				 <h2>Veículos do Cliente</h2>
					
				</div>	
    <asp:ListBox ID="LST_LISTA_VEICULOS"  Width="100%" runat="server"></asp:ListBox>
</div>

                
                
                </ContentTemplate>
                </asp:TabPanel>
            </asp:TabContainer>

       

		
		</div>

             <div class="content-box">
            <div class="softsales-form">
		<div class="softsales-form-linha">
		<asp:Button CssClass="botao-salvar" ID="BTN_SALVAR" runat="server" Text="Salvar" />
		<asp:Button CssClass="botao-cancelar" ID="BTN_CANCELAR"  CausesValidation="False" runat="server" Text="Cancelar" />
		<asp:HiddenField ID="HF_ID" runat="server" />
		</div>
		</div>
            </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ConteudoEsquerda" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ConteudoDireita" runat="server">
</asp:Content>
